home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / dvd-maxxx.com (FR).ifs < prev    next >
Text File  |  2005-03-13  |  16KB  |  555 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Bobo
  8. Title=dvd-maxxx.com
  9. Description=dvd-maxxx.com (FR) - Recherche de films
  10. Site=dvd-maxxx.com
  11. Language=FR
  12. Version=
  13. Requires=3.5.0
  14. Comments=
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program DvdMaxxx;
  23. const
  24.   ConfirmTitre = 1;
  25.     { 1: Demande le titre avant de lancer le script
  26.       2: Ne demande pas le titre avant de lancer le script, 0 : Ne demande aucune comfirmation, 3 : Aucune Confirmation Premier Film si multiples resultats}
  27.   // Pour rΘcupΘrer ou non un champs
  28.   TitreTraduitConst = True;
  29.   TitreOrignalConst = True;
  30.   CategorieConst = True;
  31.   AdresseWebConst = True;
  32.   SynopsisConst = True;
  33.  
  34. var
  35.   MovieName, Adresse, AdressePlus, La_liste, LaAllocine_FR, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon : string;
  36.   numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp : Integer;
  37.  
  38. //------------------------------------------------------------------------------
  39. // TROUVE UNE SOUS-CHAINE DE CARACTERE DANS UNE CHAINE
  40. //------------------------------------------------------------------------------
  41.  
  42. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  43. var
  44.   i: Integer;
  45. begin
  46.   result := -1;
  47.   if StartAt < 0 then
  48.     StartAt := 0;
  49.   for i := StartAt to List.Count-1 do
  50.     if Pos(Pattern, List.GetString(i)) <> 0 then
  51.     begin
  52.       result := i;
  53.       Break;
  54.     end;
  55. end;
  56.  
  57. //------------------------------------------------------------------------------
  58. // ANALYSE DE LA PAGE DE RECHERCHES
  59. //------------------------------------------------------------------------------
  60.  
  61. procedure AnalyzePage(Address: string);
  62. var
  63.   Page: TStringList;
  64.   LineNr: Integer;
  65.   Line: string;
  66.   BeginPos, EndPos : Integer;
  67. begin
  68.   Page := TStringList.Create;
  69.   Page.Text := GetPage(Address);
  70.  
  71.   if pos('Aucun produit',Page.Text) <> 0 then
  72.   begin
  73.   if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
  74.   begin
  75.     showmessage('Aucun film trouvΘ pour : '+MovieName);
  76.     exit;
  77.   end else
  78.   begin
  79.     SetField(fieldURL, 'DVD Maxxx : aucun rΘsultat');
  80.     exit;
  81.   end;
  82.   end;
  83.  
  84.     PickTreeClear;
  85.  
  86.     //on se limite α la section o∙ ya les liens du rΘsultat de la recherche
  87.     BeginPos := Pos('vAlign=bottom align="center"><A href=', Page.Text);
  88.     EndPos := length(Page.Text);
  89.     Line := copy(Page.Text,BeginPos,EndPos-BeginPos);
  90.     EndPos := Pos('produits trouvΘs', Line);
  91.     Line := copy(Line,1,EndPos-1);
  92.  
  93.     PickTreeAdd('Films trouvΘs pour ' + MovieName + ' :', '');
  94.     AddMoviesTitles(Line);
  95.     PickTreeAdd(' ', '');
  96.     PickTreeAdd('Verifier si vous avez la derniΦre version', 'version');
  97.  
  98.     if compteur = 1 then
  99.     begin
  100.       compteur := 0;
  101.       AnalyzeMoviePage();
  102.       exit;
  103.     end else if (ConfirmTitre = 1) or (ConfirmTitre = 2) then
  104.     begin
  105.       begin
  106.         if PickTreeExec(Address) then
  107.         begin
  108.           Adresse := Address;
  109.  
  110.      if (Adresse = AdressePlus) then
  111.           begin
  112.             numPageR := numPageR+1;
  113.        AnalyzePage(AdressePlus);
  114.           end else
  115.           if (Adresse = AdressePrecedent) then
  116.           begin
  117.             numPageR := numPageR-1;
  118.        AnalyzePage(AdressePrecedent);
  119.           end else
  120.           if (Adresse = AdresseSuivant) then
  121.           begin
  122.             numPageR := numPageR+1;
  123.        AnalyzePage(AdresseSuivant);
  124.           end else
  125.           begin
  126.             AnalyzeMoviePage();
  127.           end;
  128.         end;
  129.       end;
  130.     end else
  131.     begin
  132.       if (ConfirmTitre = 3) then
  133.       begin
  134.         Adresse := LePremierFilmAdresse;
  135.         AnalyzeMoviePage();
  136.       end else
  137.       begin
  138.         SetField(fieldURL, 'dvd-maxxx : rΘsultats multiples');
  139.         exit;
  140.       end;
  141.     end;
  142.   Page.Free;
  143. end;
  144.  
  145.  
  146. //------------------------------------------------------------------------------
  147. // FONCTION CONVERSION DUREE HEURES EN MINUTES
  148. //------------------------------------------------------------------------------
  149. function h2m(heures : String) : string;
  150. var
  151.   intH, intM : Integer;
  152.  
  153. begin
  154.   intH := StrToInt(copy(heures,1,1),0);
  155.   intM := StrToInt(copy(heures,3,2),0);
  156.   result := IntToStr(intH*60+intM);
  157. end;
  158.  
  159. //------------------------------------------------------------------------------
  160. // ANALYSE DE LA PAGE DU FILM
  161. //------------------------------------------------------------------------------
  162.  
  163. procedure AnalyzeMoviePage();
  164. var
  165.   Line, Value, Value2, AdresseCasting, AdresseSecret, AdresseGalerie, aucun : string;
  166.   LineNr, IntValue: Integer;
  167.   BeginPos, EndPos, FinPos, DureeProdReal: Integer;
  168. begin
  169.  
  170. //charge la page
  171.   Line := GetPage(Adresse);
  172.  
  173. // URL
  174.   if AdresseWebConst = True then
  175.   begin
  176.     if (ConfirmTitre = 3) then
  177.     begin
  178.       SetField(fieldURL, 'DVD Maxxx : α verifier');
  179.     end else
  180.     begin
  181.       SetField(fieldURL, URLEncode(Adresse));
  182.     end;
  183.   end;
  184.  
  185. //titre
  186. //exemple : <span class="txt_title">Les co-locataires - DVD</span>
  187.   if TitreTraduitConst = True then
  188.   begin
  189.   BeginPos := pos('<span class="txt_title">', Line);
  190.   delete(Line,1, BeginPos+3); // +3 : une pette marge
  191.   BeginPos := pos('>', Line)+1;
  192.   EndPos := pos('</span>', Line);
  193.   Value := copy(Line, BeginPos, EndPos - BeginPos);
  194.   if pos(' - DVD', Value) >0 then
  195.   begin
  196.     delete(Value,pos(' - DVD', Value),6);
  197.   end;
  198.   if pos(' - VHS', Value) >0 then
  199.   begin
  200.     delete(Value,pos(' - VHS', Value),6);
  201.   end;
  202.   Value := AnsiUpFirstLetter(Value);
  203.   Value := AnsiMixedCase(Value,' -');
  204.   SetField(fieldTranslatedTitle, Value);
  205.   end;
  206.  
  207. //titre originale (ici = titre)
  208.   if TitreOrignalConst = True then
  209.   begin
  210.     SetField(fieldOriginalTitle, Value);
  211.   end;
  212.  
  213. // Affiche
  214.   BeginPos := pos('<span class="txt_title">', Line);
  215.   Value := copy(Line,BeginPos, length(Line)-BeginPos+1);
  216.   BeginPos := pos('<img src=', Value)+ 10;
  217.   EndPos := pos('" align="left"', Value);
  218.   Value := copy(Value,BeginPos, EndPos-BeginPos);
  219.   if pos('https', Value) > 0 then
  220.   begin
  221.      delete(Value, pos('https', Value)+4,1);
  222.   end;
  223.   GetPicture(Value);
  224.  
  225. // RΘsumΘ
  226.   DureeProdReal := 1;
  227.   BeginPos := pos('<p> <strong>ScΘnario:</strong> ', Line)+31;
  228.   if BeginPos > 31 then
  229.   begin
  230.     Value := copy(Line,BeginPos, length(Line)-BeginPos+1);
  231.     EndPos := pos('<!-- fin scenario -->', Value)-1;
  232.     Value := copy(Value,1, EndPos);
  233.     if pos('Points forts', Value) >0 then
  234.     begin
  235.       //points forts dans Commentaires
  236.       Value2 := copy(Value, pos('Points forts', Value)+14, EndPos);
  237.       SetField(fieldComments, cleanText(Trim(Value2)));
  238.       delete(Value, pos('Points forts', Value)-1, EndPos);
  239.     end else if pos('Points Forts', Value) >0 then
  240.     begin
  241.       Value2 := copy(Value, pos('Points Forts', Value)+14, EndPos);
  242.       SetField(fieldComments, cleanText(Trim(Value2)));
  243.       delete(Value, pos('Points Forts', Value)-1, EndPos);
  244.     end;
  245.     SetField(fieldDescription, Trim(cleanText(Value)));
  246.   end else
  247.   begin
  248.     DureeProdReal := 0;
  249.     BeginPos := pos('value="Ajouter au panier"', Line);
  250.     Value := copy(Line, BeginPos, length(Line)-BeginPos+1);
  251.     BeginPos := pos('<br>', Value)+4;
  252.     EndPos := pos('<br></td></tr>', Value)-1;
  253.     Value := copy(Value,BeginPos, EndPos-BeginPos+1);
  254.     SetField(fieldDescription, Trim(cleanText(Value)));
  255.   end;
  256.  
  257. // durΘe
  258.   if DureeProdReal = 1 then
  259.   begin
  260.     BeginPos := pos('<strong>Fiche technique:</strong>', Line)+33;
  261.     Value := copy(Line,BeginPos, 30); //une marge
  262.     BeginPos := pos('durΘe', Value);
  263.     Value := copy(Value, BeginPos, 20); // marge
  264.     BeginPos := pos('h', Value)-1;
  265.     Value := copy(Value,BeginPos, 4);  //style 1h12
  266.     Value := h2m(Value);
  267.     SetField(fieldLength, Value);
  268.  
  269. // producteur
  270. // exemple : <strong>Studio:</strong> Colmax</p>
  271.     BeginPos := pos('Studio:</strong>', Line);
  272.     delete(Line,1, BeginPos+3); // +3 : une pette marge
  273.     BeginPos := pos('>', Line)+2;
  274.     EndPos := pos('</p>', Line);
  275.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  276.     SetField(fieldProducer, cleanText(Trim(Value)));
  277.  
  278. // rΘalisateur
  279. // exemple : RΘalisateur:</strong> Judy Blue
  280.     BeginPos := pos('RΘalisateur:</strong>', Line);
  281.     delete(Line,1, BeginPos+3); // +3 : une pette marge
  282.     BeginPos := pos('>', Line)+2;
  283.     EndPos := pos('<!-- fin realisateur', Line)-2;
  284.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  285.     SetField(fieldDirector, cleanText(Trim(Value)));
  286.   end;
  287.  
  288. // acteurs
  289.   BeginPos := pos('Acteurs / Actrices :', Line);
  290.   delete(Line,1, BeginPos+3); // +3 : une pette marge
  291.   BeginPos := pos('star_name=', Line);
  292.   EndPos := pos('</a></li><br clear="left">', Line);
  293.   Value := copy(Line, BeginPos, EndPos - BeginPos+5); //marge
  294.   AddActors(Value);
  295.  
  296. // Category
  297.   if CategorieConst = True then
  298.   begin
  299.     SetField(fieldCategory, 'XXX');
  300.   end;
  301.  
  302.   //DisplayResults;
  303. end;
  304.  
  305. //------------------------------------------------------------------------------
  306. // AJOUTE LES ACTEURS
  307. //------------------------------------------------------------------------------
  308.  
  309. procedure AddActors(var Line: string);
  310. var
  311.   acteurs : String;
  312.   StartPos, EndPos : Integer;
  313. begin
  314.  
  315. acteurs :='';
  316.   repeat
  317.     StartPos := pos('star_name=', Line);
  318.     if StartPos > 0 then
  319.     begin
  320.       delete(Line,1,StartPos+10);
  321.       StartPos := pos('>', Line)+1;
  322.       EndPos := pos('</a>', Line);
  323.       acteurs := acteurs + copy(Line, StartPos, EndPos-StartPos)+', ';
  324.       delete(Line,1,EndPos);
  325.     end;
  326.   until (StartPos < 1);
  327.   delete(acteurs, Length(acteurs)-1, 2);
  328.   SetField(fieldActors, Trim(acteurs));
  329. end;
  330.  
  331. //------------------------------------------------------------------------------
  332. // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT
  333. //------------------------------------------------------------------------------
  334.  
  335. procedure AddMoviesTitles(var Line: string);
  336. var
  337.   MovieTitle, MovieAddress : string;
  338.   StartPos, EndPos : Integer;
  339. begin
  340.  
  341. //compte les rΘsultats
  342.   compteur := 0;
  343.   repeat
  344.     StartPos := pos('vAlign=bottom align="center"><A href="http://www.dvd-maxxx.com', Line)+38;
  345.     if StartPos > 38 then
  346.     begin
  347.       MovieAddress := '';
  348.       MovieTitle := '';
  349.     //exemple lien : <A href="http://www.dvd-maxxx.com/?lang=fr&task=produit&prd_id=2289"
  350.     //exemple titre : <span class=nom_produit>Sinset Boulevard - DVD</span>
  351.  
  352.       EndPos := pos('" title="', Line);
  353.       MovieAddress := copy(Line, StartPos, EndPos-StartPos);
  354.      
  355.       StartPos := pos('<span class=nom_produit>', Line);
  356.       delete(Line,1,StartPos+23);
  357.       EndPos := pos('</span>', Line);
  358.       MovieTitle := copy(Line, 1, EndPos-1);
  359.       PickTreeAdd(MovieTitle, MovieAddress);
  360.       adresse := MovieAddress;
  361.       if (compteur = 0) then
  362.       begin
  363.         LePremierFilmAdresse := adresse;
  364.       end;
  365.       compteur := compteur+1;
  366.     end;
  367.   until (StartPos < 39);
  368. end;
  369.  
  370. //------------------------------------------------------------------------------
  371. // NETTOIE LES TAGS DES TEXTES
  372. //------------------------------------------------------------------------------
  373.  
  374. function cleanText(text : String) : string;
  375. var
  376.   temp : String;
  377. begin
  378.   temp := text;
  379.   temp := StringReplace(temp, #13, '');
  380.   temp := StringReplace(temp, #10, '');
  381.   temp := StringReplace(temp, '<p>', #13#10);
  382.   temp := StringReplace(temp, '</p>', #13#10);
  383.   temp := StringReplace(temp, '<br>', #13#10);
  384.   result := temp;
  385. end;
  386.  
  387. //------------------------------------------------------------------------------
  388. // NETTOIE LE TITRE DU FICHIER POUR AVOIR LE TITRE DE FILM
  389. //------------------------------------------------------------------------------
  390.  
  391. function cleanTitle(title : String) : string;
  392. var
  393.   i,j, fin : Integer;
  394.   temp : String;
  395.  
  396. begin
  397.   title := AnsiUpperCase(title);
  398.  
  399.   if title <> '' then
  400.   begin
  401. // Nettoie les tags fichiers, merci Atmosfear pour les tags
  402.   i:=pos('.DVD',title);
  403.   if i <> 0 then
  404.   begin
  405.     title := copy(title,1,i-1);
  406.   end;
  407.   i:=pos('.DIVX',title);
  408.   if i <> 0 then
  409.   begin
  410.     title := copy(title,1,i-1);
  411.   end;
  412.   i:=pos('.FREN',title);
  413.   if i <> 0 then
  414.   begin
  415.     title := copy(title,1,i-1);
  416.   end;
  417.   i:=pos('.GERM',title);
  418.   if i <> 0 then
  419.   begin
  420.     title := copy(title,1,i-1);
  421.   end;
  422.   i:=pos('.INT',title);
  423.   if i <> 0 then
  424.   begin
  425.     title := copy(title,1,i-1);
  426.   end;
  427.   i:=pos('.LIM',title);
  428.   if i <> 0 then
  429.   begin
  430.     title := copy(title,1,i-1);
  431.   end;
  432.   i:=pos('.PROP',title);
  433.   if i <> 0 then
  434.   begin
  435.     title := copy(title,1,i-1);
  436.   end;
  437.   i:=pos('.REPACK',title);
  438.   if i <> 0 then
  439.   begin
  440.     title := copy(title,1,i-1);
  441.   end;
  442.   i:=pos('.SUBB',title);
  443.   if i <> 0 then
  444.   begin
  445.     title := copy(title,1,i-1);
  446.   end;
  447.   i:=pos('.UNSUB',title);
  448.   if i <> 0 then
  449.   begin
  450.     title := copy(title,1,i-1);
  451.   end;
  452.   i:=pos('.WS',title);
  453.   if i <> 0 then
  454.   begin
  455.     title := copy(title,1,i-1);
  456.   end;
  457.   i:=pos('.XVID',title);
  458.   if i <> 0 then
  459.   begin
  460.     title := copy(title,1,i-1);
  461.   end;
  462.   i:=pos('.AC3',title);
  463.   if i <> 0 then
  464.   begin
  465.     title := copy(title,1,i-1);
  466.   end;
  467.   i:=pos('.UNRAT',title);
  468.   if i <> 0 then
  469.   begin
  470.     title := copy(title,1,i-1);
  471.   end;
  472.  
  473.    title := StringReplace(title, '.', ' ');
  474.    title := StringReplace(title, ',', ' ');
  475.    title := StringReplace(title, ':', '');
  476.    title := StringReplace(title, '-', '');
  477.    title := StringReplace(title, '  ', ' ');
  478.  
  479.    i := 0;
  480. // Nettoie les tags de team
  481.    if (pos('(',title) <> 0) then
  482.    begin
  483.      i := pos('(',title);
  484.      temp := copy(title,0,i-1);
  485.      j := pos(')',title);
  486.      fin := Length(title);
  487.      title := temp + copy(title,j+1,fin);
  488.    end;
  489.  
  490.    if (pos('[',title) <> 0) then
  491.    begin
  492.      i := pos('[',title);
  493.      temp := copy(title,1,i-1);
  494.      j := pos(']',title);
  495.      fin := Length(title);
  496.      title := temp + copy(title,j+1,fin);
  497.    end;
  498.  
  499.    title := AnsiLowerCase(title);
  500.    title := AnsiUpFirstLetter(title);
  501.    title := AnsiMixedCase(title,' -');
  502.   end;
  503.    result := title;
  504. end;
  505.  
  506. //------------------------------------------------------------------------------
  507. // PROGRAMME PRINCIPAL
  508. //------------------------------------------------------------------------------
  509.  
  510. begin
  511.   if CheckVersion(3,5,0) then
  512.   begin
  513.     numPageR := 1;
  514.     MovieName := GetField(fieldTranslatedTitle);
  515.     if MovieName = '' then
  516.       MovieName := GetField(fieldOriginalTitle);
  517.     MovieName := cleanTitle(MovieName);
  518.     if (ConfirmTitre = 1) then
  519.     begin
  520.       if Input('DVD Maxxx', 'Entrez le titre du film :', MovieName) then
  521.       begin
  522.         if Pos('dvdmaxxx.', MovieName) > 0 then
  523.         begin
  524.           adresse := MovieName;
  525.           AnalyzeMoviePage();
  526.         end else
  527.         begin
  528.           AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  529.         end;
  530.       end;
  531.     end else
  532.     begin
  533.       if (premiereExecution = 0) then
  534.       begin
  535.           premiereExecution := -1;
  536.      PickTreeClear;
  537.          PickTreeAdd('Vous allez executer le script DVD Maxxx sans confirmation', '');
  538.           PickTreeAdd('Cliquez ici pour continuer', 'Oui');
  539.      PickTreeAdd('Cliquez sur annuler pour ne pas executer le script', '');
  540.      begin
  541.        if PickTreeExec(Reponse)=true then
  542.              if (Reponse = 'Oui') then
  543.              begin
  544.               AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  545.        end;
  546.      end;
  547.       end else
  548.       begin
  549.           AnalyzePage('http://www.dvd-maxxx.com/index.php?task=search&keywords='+UrlEncode(MovieName));
  550.       end;
  551.     end;
  552.   end else
  553.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  554. end.
  555.